Pass through --extra-settings to worker processes#80
Conversation
| extra_settings = options['extra_settings'] | ||
| if extra_settings is not None: | ||
| load_extra_settings(extra_settings) | ||
| super().handle_extra_settings(**options) |
There was a problem hiding this comment.
Have you considered just making this part of handle on the super class and then having subclasses call super().handle(...) instead of a custom method?
I can't see any weird side effects and it's probably a bit more expected when going through inheritance.
There was a problem hiding this comment.
I did, unfortunately Django's BaseCommand.handle raises NotImplementedError so we'd need where to stop the super() calls to avoid errors and also means that calling super().handle(...) in an implementation could easily look like it's a bug.
I also considered an approach of adding this functionality as a decorator (which would make it harder to get wrong) however that felt more complicated (class decorators being more complicated than function ones) and likely wouldn't have a great way to support the return value.
This introduces a base command class which handles the extra settings since they're now in quite a few places, then uses that as part of passing through the extra settings to the worker processes.
Tested manually using an extra settings file containing
import sys; print(sys.argv)and checking that it gets run for the worker process.This changes the signature of the
runnerfunction, however as that's not meant to be a public API I'm not considering it a breaking change.Fixes #78